package com.role.serivce;

import com.microservice.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.stereotype.Service;

import com.role.dao.RoleMapper;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleService {

	@Autowired
	private RoleMapper roleMapper;
	
	public Role getRoleById(Integer id) {
		return roleMapper.selectByPrimaryKey(id);
	}


	public List<Role> getRolesByUserId(Integer userId){
		return roleMapper.getRolesByUserId(userId);
	}

	@Transactional
	public int save(){
		Role role = new Role();
		role.setRemark("测试事务");
		role.setRolename("testTransactional");
//		return roleMapper.insert(role);
		roleMapper.insert(role);

		throw new RuntimeException();
	}

}
